package com.roy.eureka.server.service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;
import com.roy.eureka.api.dto.LoginDTO;
import com.roy.eureka.api.message.RequestMessage;
import com.roy.eureka.server.util.MessageUtil;

@Controller
@RequestMapping("/SwordRisk")
public class SwordRiskServiceImpl {

	private static final Logger logger = LoggerFactory.getLogger(SwordRiskServiceImpl.class);
	
	@ResponseBody
	@RequestMapping(value="/getSwordRiskRes",method={RequestMethod.POST,RequestMethod.GET})
	public Object getSwordRiskRes(@RequestBody RequestMessage request){
		logger.info("received request : "+request);
		return null;
	}
	
	@ResponseBody
	@RequestMapping(value="/swordRiskTest",method={RequestMethod.POST,RequestMethod.GET})
	public String swordRiskTest(@RequestParam(value="test") String test){
		logger.info("received test request : "+test);
		return "received.test = "+test;
	}
	//用户 登录 服务
	@ResponseBody
	@RequestMapping(value="/loginChk",method={RequestMethod.POST,RequestMethod.GET})
	public RequestMessage loginChk(@RequestBody LoginDTO loginDto){
		logger.info("received loginChk request : "+JSON.toJSONString(loginDto));
		RequestMessage requestMessage = MessageUtil.getRequestMessage(loginDto,LoginDTO.class);
		logger.info("send to engine requestId[{}] requestMessage: {}",
				requestMessage.getRequestId(),requestMessage.toString());
		return requestMessage;
	}
}
